package com.hzcx.app.simplechat.ui.moment.presenter;

import android.content.Context;

import com.hzcx.app.simplechat.api.BaseDialogObserver;
import com.hzcx.app.simplechat.api.BaseObserver;
import com.hzcx.app.simplechat.base.BaseEmptyBean;
import com.hzcx.app.simplechat.base.BasePresenter;
import com.hzcx.app.simplechat.model.MomentModel;
import com.hzcx.app.simplechat.ui.moment.bean.MomentBean;
import com.hzcx.app.simplechat.ui.moment.bean.NewMessageListBean;
import com.hzcx.app.simplechat.ui.moment.contract.NewMessageContract;
import com.hzcx.app.simplechat.ui.moment.contract.UserMomentContract;

import java.util.List;

public class NewMessagePresenter extends BasePresenter<NewMessageContract.View> implements NewMessageContract.Presenter {


    /**
     * 获取新消息列表
     *
     * @param context
     * @param page
     */
    @Override
    public void getNewMessageList(Context context, int page) {
        MomentModel.getNewMessageList(context, page, new BaseObserver<List<NewMessageListBean>>() {
            @Override
            protected void onSuccess(List<NewMessageListBean> data) {
                mView.messageResult(data);
            }

            @Override
            public void onFailure(Throwable e, String errorMsg) {
                super.onFailure(e, errorMsg);
                mView.onFail();
            }
        });
    }

    /**
     *  清空消息列表
     * @param context
     */
    @Override
    public void clearNewMessageList(Context context) {
        MomentModel.clearNewMessageList(context, new BaseDialogObserver<BaseEmptyBean>(context) {
            @Override
            protected void onSuccess(BaseEmptyBean data) {
                mView.clearSuccess();
            }
        });
    }
}
